<html>
<head><meta charset="utf-8"><title>Recursive opaque types · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html">Recursive opaque types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214446058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446058">(Oct 24 2020 at 19:53)</a>:</h4>
<p>For <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f4adbdff95841b974ef0a63fd045a6b8">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f4adbdff95841b974ef0a63fd045a6b8</a></p>
<p>Can someone explain the error in <code>f</code> here? I feel like either both should not work or both should?</p>



<a name="214446258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446258">(Oct 24 2020 at 19:57)</a>:</h4>
<p>Returning <code>impl Trait</code> has to resolve to a specific type in the function body. In <code>g</code> that's <code>vec::IntoIter</code>, but in <code>f</code> it's completely unknown.</p>



<a name="214446321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446321">(Oct 24 2020 at 19:58)</a>:</h4>
<p>I don't know why the error calls it "recursive" though</p>



<a name="214446546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446546">(Oct 24 2020 at 20:02)</a>:</h4>
<p>The recursive opaque type error is supposed to be for opaque types where the concrete type uses, but is not equal to the opaque type itself. For example</p>



<a name="214446550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446550">(Oct 24 2020 at 20:03)</a>:</h4>
<p>You can give it a type like <code>Err::&lt;std::iter::Empty&lt;i32&gt;, _&gt;(err)</code></p>



<a name="214446579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446579">(Oct 24 2020 at 20:03)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">f</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="nb">Sized</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">[</span><span class="n">f</span><span class="p">()]</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>Where the return type has to satisfy <code>T = [T; 1]</code></p>



<a name="214446634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446634">(Oct 24 2020 at 20:04)</a>:</h4>
<p>If the opaque type actually equals the resolved type it should have a different note.</p>



<a name="214446670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Recursive%20opaque%20types/near/214446670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Recursive.20opaque.20types.html#214446670">(Oct 24 2020 at 20:05)</a>:</h4>
<p>Ok, so that is misapplied in this case?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>